/*
	Name: 
	Copyright: 
	Author: 
	Date: 18/03/14 15:47
	Description: TIm sinh vien co tong diem > 5
*/

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
// Thong tin sinh Vien
typedef struct  {
	char mssv[10];
	char name[30];
	int age;
	float tongdiem;
} sinhvien;

int main(){

	sinhvien sv[10];
	int soSV;
	printf("\n Nhap so sinh vien: ");
	scanf("%d",&soSV);
	// Nhap thong tin sinh vien
	for( int i = 0; i < soSV ; i++){
		printf("\n Nhap thong tin sinh vien: %d", i);
		printf("\n Nhap ma so sinh vien: ");
		scanf("%s",&sv[i].mssv); 
		fflush(stdin);
		printf("\n Nhap Ho ten sinh vien: ");
		gets(sv[i].name);
		lbNhapTuoi:
		printf("\n Nhap Tuoi sinh vien: ");
		scanf("%d",&sv[i].age);
		if( sv[i].age < 0 || sv[i].age > 200){
			printf("\n Nhap lai Tuoi sinh vien: ");
			goto lbNhapTuoi;
		}
		printf("\n Nhap tong diem sinh vien: ");
		scanf("%f",&sv[i].tongdiem);
	}
	// Xuat Thong tin sinh vien
	printf("\n-----------THONG TIN SINH VIEN ----------\n");
	printf("MSSV        NAME        AGE\n");
	for(int  i = 0 ; i< soSV ; i ++){
		printf("%s\t",sv[i].mssv);
		printf("%s\t",sv[i].name);
		printf("%d\t\t",sv[i].age);
		printf("\n");
	}
	// Tim va in ra cac sinh vien co tong diem > 5
	printf("\n Cac sinh vien > 5: \n");
	for(int i = 0;  i< soSV ; i++){
		if( sv[i].tongdiem > 5){
			printf("%s\t",sv[i].name);
		}
	}
	getch();
}
